-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HOLD] Feat: Update how GBR is determined for IOU/expense reports #29778
[HOLD] Feat: Update how GBR is determined for IOU/expense reports #29778
Conversation
@@ -116,8 +116,7 @@ function OptionRowLHN(props) { | |||
|
|||
const hasBrickError = optionItem.brickRoadIndicator === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR; | |||
const defaultSubscriptSize = optionItem.isExpenseRequest ? CONST.AVATAR_SIZE.SMALL_NORMAL : CONST.AVATAR_SIZE.DEFAULT; | |||
const shouldShowGreenDotIndicator = | |||
!hasBrickError && (optionItem.isUnreadWithMention || optionItem.isWaitingForTaskCompleteFromAssignee || ReportUtils.isWaitingForIOUActionFromCurrentUser(optionItem)); | |||
const shouldShowGreenDotIndicator = !hasBrickError && (optionItem.isUnreadWithMention || optionItem.isWaitingForTaskCompleteFromAssignee || ReportUtils.shouldShowGBR(optionItem)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be cleaner if we move isUnreadWithMention and isWaitingForTaskCompleteFromAssignee into the shouldShowGBR function. So all the logic of when to show GBR is in there.
tests/unit/SidebarOrderTest.js
Outdated
@@ -431,7 +430,7 @@ describe('Sidebar', () => { | |||
expect(screen.queryAllByTestId('Pin Icon')).toHaveLength(1); | |||
expect(screen.queryAllByTestId('Pencil Icon')).toHaveLength(1); | |||
expect(lodashGet(displayNames, [0, 'props', 'children'])).toBe('One, Two'); | |||
expect(lodashGet(displayNames, [1, 'props', 'children'])).toBe('Email Two owes $100.00'); | |||
expect(lodashGet(displayNames, [1, 'props', 'children'])).toBe('Email Two paid $100.00'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this change from owes
to paid
if all we're doing in this PR is determining whether or not the GBR should be displayed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about the same thing, but tests were failing, because they were receiving this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably more places where “ hasOutstandingIOU” was doing something
Cc: @puneetlath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I assumed tests failing meant something probably broke in the logic. 😅
Will wait for input from @puneetlath.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akinwale updated, changed to previous, hasOutstandingIOU was needed for a correct behaviour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this change is no longer in the code? I didn't see it when reviewing.
src/libs/SidebarUtils.js
Outdated
@@ -179,7 +179,7 @@ function getOrderedReportIDs(currentReportId, allReportsDict, betas, policies, p | |||
reportsToDisplay.forEach((report) => { | |||
if (report.isPinned) { | |||
pinnedReports.push(report); | |||
} else if (ReportUtils.isWaitingForIOUActionFromCurrentUser(report)) { | |||
} else if (ReportUtils.shouldShowGBR(report)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having a separate section for outstandingIOUReports
. Can we just include this in the pinned reports group?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will cause multiple changes in tests, but sure, will do that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you prefer to handle it in a separate PR that is also fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to have it sorted together?
I mean we always want to have pinned and just after green dots
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'd just do if (report.isPinned || ReportUtils.shouldShowGBR(report)) pinnedReports.push(report);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But what if green dot report will be before the pinned report, is it a correct behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep that's fine. We want them to be treated the same from an ordering perspective.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep that's fine. We want them to be treated the same from an ordering perspective.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated and updated few tests as it doesnt sort IOU reports and pinned and IOU reports have the same order priority
@waterim are you sure this is working in #focus mode? I tried testing it with an account that had |
Will test it once again, was working, but maybe was testing in a wrong way |
@puneetlath Fixed the issue and resolved conflicts! |
// Current user is an admin and the report has been approved but not settled yet | ||
return policy.role === CONST.POLICY.ROLE.ADMIN && isReportApproved(report); | ||
if (report.isWaitingForTaskCompleteFromAssignee) { | ||
return true; | ||
} | ||
|
||
// Money request waiting for current user to add their credit bank account |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@waterim actually, we've decided to treat this condition like the others. If a report is waiting on bank account, we will add the hasOutstandingChildRequest
to the parent for the submitter and show the green dot on the parent. So let's remove this condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@waterim I think we should remove this whole block:
// Money request waiting for current user to add their credit bank account
// hasOutstandingIOU will be false if the user paid, but isWaitingOnBankAccount will be true if user don't have a wallet or bank account setup
if (!report.hasOutstandingIOU && report.isWaitingOnBankAccount && report.ownerAccountID === currentUserAccountID) {
return true;
}
@puneetlath Resolved conflicts once again, second time for the last 3 hours :D |
@puneetlath no conflicts, please try to refresh the page |
Reviewer Checklist
Screenshots/Videos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Tests well.
// Current user is an admin and the report has been approved but not settled yet | ||
return policy.role === CONST.POLICY.ROLE.ADMIN && isReportApproved(report); | ||
if (report.isWaitingForTaskCompleteFromAssignee) { | ||
return true; | ||
} | ||
|
||
// Money request waiting for current user to add their credit bank account |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@waterim I think we should remove this whole block:
// Money request waiting for current user to add their credit bank account
// hasOutstandingIOU will be false if the user paid, but isWaitingOnBankAccount will be true if user don't have a wallet or bank account setup
if (!report.hasOutstandingIOU && report.isWaitingOnBankAccount && report.ownerAccountID === currentUserAccountID) {
return true;
}
* Determines if a report has an IOU that is waiting for an action from the current user (either Pay or Add a credit bank account) | ||
* Determines if a report should show a GBR (green dot) in the LHN. This can happen when the report: | ||
- is unread and the user was mentioned in one of the unread comments | ||
- is for an outstanding task waiting on the user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the task case covered in the function. Shouldn't it be?
const draftReports: Report[] = []; | ||
const nonArchivedReports: Report[] = []; | ||
const archivedReports: Report[] = []; | ||
reportsToDisplay.forEach((report) => { | ||
if (report.isPinned) { | ||
if (report.isPinned ?? ReportUtils.shouldShowGBR(report)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ??
instead of ||
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New lint rules
@waterim I pushed some commits to try to get it merged today. I hope you don't mind! |
@puneetlath ah, sure, no problem, sorry for a late answer, thats a Halloween night and was not near to computer during the evening |
All good! We got it across the finish line 🙌🏾 |
Details
This PR is to add tests to IOUTests.js file for submitReport function
Fixed Issues
$ #29595
Tests
N/A
Offline tests
Same as tests
QA Steps
N/A
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Behaviour is the same for all platforms, attaching screenshots for focused and most recent for IOU green dot
Web
Most recent:
Focus: